package com.lagouedu.controller;

import com.lagouedu.pojo.R;
import com.lagouedu.service.MailService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/email")
public class MailController {

    @Reference
    private MailService mailService;

    @RequestMapping("/{email}/{code}")
    public R sendEmail(@PathVariable("email") String email,@PathVariable("code") String code){
        try {
            mailService.sendSimpleMail(email,"lagouedu验证码", code);
            return R.ok("验证码发送成功！");
        } catch (Exception e){
            return R.ok("验证码发送失败！");
        }
    }
}
